package com.hy.controller;

import com.hy.Result.ResponseResult;
import com.hy.service.AppHospitaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 医院控制器-App端
 */
@RestController
@RequestMapping("/api/app/hospital")
public class AppHospitaController {

    @Autowired
    private AppHospitaService appHospitalService;
    /**
     * 根据医院ID查询医院名称
     * @param id 医院ID
     * @return 医院名称
     */
    @GetMapping("/name")
    public ResponseResult getHospitalNameById(@RequestParam("id") Long id) {
        return appHospitalService.getHospitalNameById(id);
    }


    /**
     * 医院列表
     * @return ResponseResult
     */
    @RequestMapping("/list")
    public ResponseResult list(){
        try {
            return appHospitalService.list();
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseResult.errorResult(400, "医院查询失败!");
        }
    }


}
